<template>
	<!-- //审批拒绝弹窗 -->
	<el-dialog :title="type == 1 ? '审核拒绝' : '结束订单'" center v-model="dialogVisible" width="536" class="radius8" :before-close="handleClose">
		<div>
			<div class="fs16">
				{{type == 1 ? '否决订单，需要填写否决原因' : '是否结束订单，需要填写结束原因'}}
			</div>
			<div class="mt15">
				<el-input size="large" type="textarea" resize="none" class="textReset"
				show-word-limit v-model="reason"
					:rows="6"  :placeholder="type == 1 ? '请填写否决订单原因' : '请填写结束订单原因'" maxlength="300" />
			</div>
			<div slot="footer" class="dialog-footer text-right mt30">
				<el-button class="cancelSubBtn" @click="result = '',dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="resultSubmit()" class="mainSubBtn">确 定</el-button>
			</div>
		</div>
	</el-dialog>
</template>

<script>
	import{
		auditOrder,
		orderEnd//结束订单
	} from "@/api/business/order"
	export default{
		props:{
			id:{
				type:String,
				default:'',//结束订单的id
			},
			item:{
				type:Object,
				default:res=>{return {}}
			},
			type:{
				type:Number,
				default:1,//1：默认审核拒绝 0：结束订单
			},
		},
		data(){
			return{
				dialogVisible:false,//结束订弹窗
				reason:''
			}
		},
		methods:{
			open(){
				this.dialogVisible = true
			},
			handleClose(){
				this.dialogVisible = false
			},
			//提交
			resultSubmit(){
				//审核拒绝
				if(this.type == 1){
					this.item.flyflow.approveResult = false
					this.item.flyflow.approveDesc = this.reason
					auditOrder(this.item).then(res=>{
						this.$modal.msgSuccess('已提交')
						this.dialogVisible = false
						this.$emit('refresh')
					})
				}else{
					//结束订单
					let data = {
						id:this.id,
						operationContent:this.reason
					}
					orderEnd(data).then(res=>{
						this.$modal.msgSuccess('已提交')
						this.dialogVisible = false
						this.$emit('refresh')
					})
				}
				
			}
		}
	}
</script>

<style>
</style>